//package cn.ztuo.bitrade.job;
//
//import com.left.Result;
//import com.left.runnable.MyRunnable1;
//import com.left.runnable.MyRunnable2;
//import com.left.util.ResultUtils;
//import com.left.utils.YouXinConfiguration;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.scheduling.Trigger;
//import org.springframework.scheduling.TriggerContext;
//import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
//import org.springframework.scheduling.support.CronTrigger;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.Date;
//import java.util.concurrent.ScheduledFuture;
//
///**
// * <pre>
// *    @author : orange
// *    @e-mail : 495314527@qq.com
// *    @time   : 2018/8/28 16:15
// *    @desc   : 定时任务
// *    @version: 1.0
// * </pre>
// */
//@Slf4j
//@RestController
//@RequestMapping("/quartz/task")
//public class DynamicTaskController {
//
//    @Autowired
//    private YouXinConfiguration youXinConfiguration;
//
//    @Autowired
//    private ThreadPoolTaskScheduler threadPoolTaskScheduler;
//
//    private ScheduledFuture<?> future1;
//
//    private ScheduledFuture<?> future2;
//
//    @Bean
//    public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
//        return new ThreadPoolTaskScheduler();
//    }
//
//    @PostMapping("/startCron1")
//    public Result startCron1() {
//
//        future1 = threadPoolTaskScheduler.schedule(new MyRunnable1(),new Trigger(){
//            @Override
//            public Date nextExecutionTime(TriggerContext triggerContext){
//                return new CronTrigger(youXinConfiguration.getCorn1()).nextExecutionTime(triggerContext);
//            }
//        });
//
//        System.out.println("DynamicTask.startCron1()");
//
//        return ResultUtils.success();
//
//    }
//
//    @PostMapping("/stopCron1")
//    public Result stopCron1() {
//        if (future1 != null) {
//            future1.cancel(true);
//        }
//        System.out.println("DynamicTask.stopCron1()");
//        return ResultUtils.success();
//    }
//
//
//    @PostMapping("/startCron2")
//    public Result startCron2() {
//
//        future2 = threadPoolTaskScheduler.schedule(new MyRunnable2(),new Trigger(){
//            @Override
//            public Date nextExecutionTime(TriggerContext triggerContext){
//                return new CronTrigger(youXinConfiguration.getCorn2()).nextExecutionTime(triggerContext);
//            }
//        });
//
//        System.out.println("DynamicTask.startCron2()");
//
//        return ResultUtils.success();
//
//    }
//
//    @PostMapping("/stopCron2")
//    public Result stopCron2() {
//        if (future2 != null) {
//            future2.cancel(true);
//        }
//        System.out.println("DynamicTask.stopCron2()");
//        return ResultUtils.success();
//    }
//
//}
